<template>
  <div o-Container>
    <o-list v-bind:source="list.contract" v-bind="{ exported: output }">
      <template slot="config" slot-scope="scope">
        <div class="img_box">
          <img @click="showLookDiaolog(scope)" src="/static/skin/default/MCS/AIGC/Inventory/images/chakan.png" alt="">
        </div>
      </template>
    </o-list>
    <ApplyMsg ref="ApplyMsg" :messageList="messageList" @refresh="refresh"></ApplyMsg>
  </div>
</template>

<script>
import ApplyMsg from '../Components/ApplyMsg.vue'
import EditInvoice from '../Components/EditInvoice.vue'
export default {
  components: {
    ApplyMsg,
    EditInvoice
  },
  name: "mms_platform_company_list", /* 这个name暂时不知道用啥用，根据官方文档说的是方便排错的 */
  data() {
    return {
      octopus: this.$parent.octopus,
      list: {
        contract: {
          data: {
            id: 1393, // 菜单表的八爪鱼ID
            cellData: [
              { name: "PayCode", width: 200 },	// 订单编号
              { name: "Name", width: 300 },	// 权益名称
              { name: "Quantity" },	// 已核销数量
              { name: "UserPayTotalPrice" },	// 已核销金额(元)
              { name: "CompanyID", show: false },	// 卖家
              { name: "CompanyIDName" },	// 卖家
              { name: "Status" },	// 发票状态
              { name: "StatusID", show: false },	// 发票状态
              { name: "RefundAmount", },	// 退款金额
              { name: "RefundQuantity", },	// 退款数量
              { name: "PayTime", width: 160 },	// 购买时间
              { name: "Amount", show: false },	// 申请开票金额(元)
              { name: "BankAccount", show: false },	// 银行账户
              { name: "BankName", show: false },	// 开户银行
              { name: "CompanyAddress", show: false },	// 单位地址
              { name: "CompanyName", show: false },	// 单位名称
              { name: "CreateTime", show: false },	// 申请开票时间
              { name: "FilePath", show: false },	// 附件
              { name: "ID", show: false },	// ID
              { name: "IsVat", show: false },	// 是否增值税发票
              { name: "Mail", show: false },	// 开票人 邮箱
              { name: "Phone", show: false },	// 单位电话
              { name: "ReopenTime", show: false },	// 撤销发票时间
              { name: "TaxCode", show: false },	// 税号
              { name: "EquityID", show: false },	// EquityID
              { name: "InvoiceID", show: false },	// InvoiceID
              { name: "TradeTypeID", show: false },	// TradeTypeID
              { name: "TypeID", show: false },	// TypeID
              { name: "MerchantID" , show: false},	// 买家ID
              { name: "MerchantIDName", show: false },	// 买家名称
            ],
            paramData: {
              // CompanyID: 267296
              UserID: ''
            }
          },
          configWidth: 35,
          showNumber: true,
        },
      },
      messageList: {},
      messageListAdd: {},
    }
  },
  created() {
    this.init();
  },
  methods: {
    init() {
      // const cellData = this.list.contract.data.cellData;
      // // 遍历 cellData，找到符合条件的元素，并添加键值对
      // cellData.forEach(item => {
      //   if (item.name === "CompanyID") {
      //     // 添加 filterKey 和 filterValue
      //     item.filterKey = '=';
      //     item.filterValue = this.octopus.passport.authorization.company == 1 ? '' : this.octopus.passport.authorization.company;
      //   }
      // })
      const paramData = this.list.contract.data.paramData;
      paramData.UserID = this.octopus.passport.id
    },
    showLookDiaolog(row) {
      this.messageList = row.data.row
      this.$refs.ApplyMsg.drawerOp()
    },
    output: function (data) {
      this.octopus.tips.success("下载完成。");
    },
    search: function (cell) {
    },
    save: function (data) {// 保存
      this.octopus.tips.success(data);
      // 刷新list
      this.list.contract.control.load();
      this.back();
    },
    back: function () {
      this.panel.visible = false;
    },
    del: function (row) {
      let o = this
      // alert("del key: " + JSON.stringify(row));
      this.$confirm('此操作将永久删除该项, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.octopus.request.api.post("/Octopus/Engine/Item", {
          id: 1188, // 菜单表的八爪鱼ID
          type: "DELETE",
          value: row.ID,
          cellData: [
            { name: "ID", defaultValue: row.ID },
          ],
        },
          // 处理回调事件，通过分析data.status.code的状态来实现。
          function (data) {
            if (data.status.code === 200) {
              o.list.contract.control.load();
            } else {
              o.octopus.tips.error(data);
            }
          }
        );
        this.$message({
          type: 'success',
          message: '删除成功!'
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '已取消删除'
        });
      });
    },
    refresh() {
      this.list.contract.control.load();
    },
  },
  props: ["oData"]
}
</script>
<style scoped>
.el-message-box {
  background-color: #fff !important;
}

.img_box {
  display: flex;
  justify-content: space-between;
  width: 100%;
}

.img_box img {
  width: 25px;
  cursor: pointer;
}
</style>